﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HZ.Supervise.IBLL;
using HZ.Supervise.Model;
namespace HZ.Supervise.Web.Common
{
    public partial class SortControls : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                banding();
            }
        }
        //绑定类别
        private void banding()
        {
            int t = 0;
            HZ.Supervise.IBLL.IExecuteContext ie = HZ.Supervise.BLLFactory.ExecuteContext();
            ie.QueryObject = new HZ.Supervise.Model.QueryObject()
            {
                GroupField = GroupByField.SortID,
                SortField = "SortID"
            };
            System.Data.DataTable dt = ie.Execute();

            this.ddlSortName.DataTextField = "SortName";
            this.ddlSortName.DataValueField = "SortName";
            this.ddlSortName.DataSource = dt;
            this.ddlSortName.DataBind();

            ListItem item = new ListItem();
            item.Text = "全部";
            item.Value = "";
            ddlSortName.Items.Insert(0, item);
        }
        public string SortName
        {
            get
            {
                if (ddlSortName.Text.Trim() == "全部")
                {
                    return "";
                }
                else
                {
                    return ddlSortName.Text.Trim();
                }
            }
            set
            {
                if (value != null)
                    ddlSortName.Text = value.Trim() == "" ? "全部" : value;
            }
        }
    }
}